home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-30 | 8.4 KB | 435 lines | [TEXT/CWIE] |
- { Stuff.p }
- { Created 10/30/98 1:06 PM by AppMaker }
-
- Unit Stuff;
- Interface
-
- Uses
- Types,
- Quickdraw,
- Controls,
- Dialogs,
- Events,
- Lists,
- Menus,
- Resources,
- TextEdit,
- ToolUtils,
-
- DDocData,
- EverythingEngine,
- EverythingDoc,
- AMWindow;
-
- type
- Stuff = object (AMWindow)
-
- {data members}
- mData: DDocData;
- mToolsHandle: ControlHandle;
- mPopupsHandle: ControlHandle;
- mFromValuesList2Handle: ControlHandle;
- mFromMenuHandle: ControlHandle;
- mListsHandle: ControlHandle;
- mTextListHandle: ControlHandle;
-
- {methods}
- Procedure Initialize; Override;
-
- Procedure Open (inDoc: EverythingDoc;
- inData: DDocData);
- Procedure Close; Override;
-
- Procedure Control (whichControl: ControlHandle;
- whichPart: integer;
- where: Point); Override;
- Procedure MouseIn (where: Point;
- modifiers: integer); Override;
- Procedure TypeIn (charCode: SInt16); Override;
- Procedure ExitCurField; Override;
- Procedure DataChanged (inDataID: longint); Override;
- Procedure Resize; Override;
- Procedure Scroll (newValue: integer;
- oldValue: integer); Override;
-
- Function GetEngine: EverythingEngine;
-
- Procedure BuildTextListList (inControl: ControlHandle);
- {$ifc false}
- Procedure UpdateMenus; Override;
- {$endif}
- Function DoCommand (inCommand: longint): Boolean; Override;
-
- Procedure DoUndo;
- Procedure DoCut;
- Procedure DoCopy;
- Procedure DoPaste;
- Procedure DoClear;
- Procedure DoSelectAll;
- Procedure DoShowClipboard;
-
- end;
-
- {----------}
- Procedure CreateStuff (inDoc: EverythingDoc;
- inData: DDocData);
-
- {----------}
- Implementation
-
- Uses
- Globals,
- ResourceDefs,
- DoScrap,
- Scrolling,
- ControlUtils,
- Miscellany;
-
- const
- kToolsPalette = 1;
- kPopupsBox = 2;
- kFromValuesList2Popup = 3;
- kFromMenuPopup = 4;
- kListsBox = 5;
- kTextListList = 6;
-
- {----------}
- Procedure CreateStuff (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- winObj: Stuff;
- begin
- winObj := nil;
- New (winObj);
-
- if winObj <> nil then begin
- winObj.Initialize;
- winObj.Open (inDoc, inData);
- end;
- end;
-
- {----------}
- Procedure Stuff.Initialize;
- begin
- Inherited Initialize;
- end;
-
- {----------}
- Function Stuff.GetEngine: EverythingEngine;
- begin
- GetEngine := EverythingEngine (mDoc.mEngine);
- end;
-
- {----------}
- Procedure Stuff.Open (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- window: WindowPtr;
- wftb: Handle;
- errCode: OSErr;
- begin
- mDoc := inDoc;
- mData := inData;
- mData.AddResponder (self);
-
- window := GetNewCWindow (WIND_Stuff, nil, WindowPtr (-1));
- if inDoc.mEngine.GetFilename <> '' then begin
- SetWTitle (window, inDoc.mEngine.GetFilename);
- end;
- mWindow := window;
- EverythingDoc (mDoc).mStuffPtr := window;
-
- WindowPeek (window)^.windowKind := kAMWindowFlag;
- SetWRefCon (window, ord4 (self));
- SetPort (window);
- SetInfo (window);
-
- wftb := GetResource ('Wftb', WIND_Stuff);
-
- errCode := CreateRootControl (window, mRootControl);
-
- vScroll := nil;
- hScroll := nil;
-
-
- mToolsHandle := GetNewControl (CNTL_Tools, window);
- SetWindowItemFont (mToolsHandle, wftb, 1);
- SetControlValue (mToolsHandle, mData.GetTools);
-
- mPopupsHandle := GetNewControl (CNTL_Popups, window);
- SetWindowItemFont (mPopupsHandle, wftb, 2);
-
- mFromValuesList2Handle := GetNewControl (CNTL_FromValuesList2, window);
- errCode := EmbedControl (mFromValuesList2Handle, mPopupsHandle);
- SetWindowItemFont (mFromValuesList2Handle, wftb, 3);
- SetControlValue (mFromValuesList2Handle, mData.GetFromValuesList2);
-
- mFromMenuHandle := GetNewControl (CNTL_FromMenu, window);
- errCode := EmbedControl (mFromMenuHandle, mPopupsHandle);
- SetWindowItemFont (mFromMenuHandle, wftb, 4);
- SetControlValue (mFromMenuHandle, mData.GetFromMenu);
-
- mListsHandle := GetNewControl (CNTL_Lists, window);
- SetWindowItemFont (mListsHandle, wftb, 5);
-
- mTextListHandle := GetNewControl (CNTL_TextList, window);
- errCode := EmbedControl (mTextListHandle, mListsHandle);
- SetWindowItemFont (mTextListHandle, wftb, 6);
- BuildTextListList (mTextListHandle);
- SetListBoxChoice (mTextListHandle, mData.GetTextList);
-
- errCode := AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- end;
-
- {----------}
- Procedure Stuff.Close;
- begin
- mData.RemoveResponder (self);
-
- EverythingDoc (mDoc).mStuffPtr := nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- Dispose (self);
- end;
-
- {----------}
- Procedure Stuff.BuildTextListList (
- inControl: ControlHandle);
- var
- list: ListHandle;
- begin
- list := GetListHandle (inControl);
- AddToList ("One", list);
- AddToList ("Two", list);
- AddToList ("Three", list);
- AddToList ("Infinity", list);
-
- end;
-
- {----------}
- Procedure Stuff.Control (
- whichControl: ControlHandle;
- whichPart: integer;
- where: Point);
- var
- bounds: Rect;
- newValue: integer;
- partcode: SInt16;
- begin
- ExitCurField ();
-
- if whichControl = mToolsHandle then begin
- if TrackClick (mToolsHandle, where) then begin
- mData.SetTools (GetControlValue (mToolsHandle));
- end;
- end;
- if whichControl = mFromValuesList2Handle then begin
- if TrackClick (mFromValuesList2Handle, where) then begin
- mData.SetFromValuesList2 (GetControlValue (mFromValuesList2Handle));
- end;
- end;
- if whichControl = mFromMenuHandle then begin
- if TrackClick (mFromMenuHandle, where) then begin
- mData.SetFromMenu (GetControlValue (mFromMenuHandle));
- end;
- end;
- if whichControl = mTextListHandle then begin
- if TrackClick (mTextListHandle, where) then begin
- mData.SetTextList (GetListBoxChoice (mTextListHandle));
- end;
- end;
- end;
-
- {----------}
- Procedure Stuff.DataChanged (
- inDataID: longint);
- begin
- if inDataID = idTools then begin
- SetControlValue (mToolsHandle, mData.GetTools);
- end;
- if inDataID = idFromValuesList2 then begin
- SetControlValue (mFromValuesList2Handle, mData.GetFromValuesList2);
- end;
- if inDataID = idFromMenu then begin
- SetControlValue (mFromMenuHandle, mData.GetFromMenu);
- end;
- End;
-
- {----------}
- Procedure Stuff.MouseIn (
- where: Point;
- modifiers: integer);
- var
- bounds: Rect;
- begin
- end;
-
- {----------}
- Procedure Stuff.ExitCurField;
- var
- errCode: OSErr;
- focus: ControlHandle;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- if focus = nil then begin
- { nothing to exit }
-
- end;
- inherited ExitCurField;
- end;
-
- {----------}
- Procedure Stuff.TypeIn (
- charCode: SInt16);
- var
- ch: char;
- errCode: OSErr;
- focus: ControlHandle;
- keyCode: SInt16;
- partcode: SInt16;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- ch := chr (charCode);
- if (ch = charEnter)
- | (ch = charReturn) then begin
- ExitCurField;
- end else if ch = charEsc then begin
- end else if ch = charTab then begin
- DoTab (BAnd (curEvent.modifiers, optionKey) <> 0);
- end else if focus <> nil then begin
- keyCode := BAnd (curEvent.message, keyCodeMask);
- partcode := HandleControlKey (focus, keyCode, charCode, curEvent.modifiers);
- mDoc.mEngine.SetDirty;
- end else begin
- SysBeep (1);
- end;
- end;
-
- {----------}
- Procedure Stuff.Resize;
- begin
- { application-specific code to resize items in window }
- end;
-
- {----------}
- Procedure Stuff.Scroll (
- newValue: integer;
- oldValue: integer);
- begin
- { application-specific code to scroll window }
- if gWhichScroll = vScroll then begin
- end else begin { horizontal }
- end;
- end;
-
- {----------}
- Procedure Stuff.DoUndo;
- begin
- end; {DoUndo}
-
- {----------}
- Procedure Stuff.DoCut;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECut (curTE);
- mDoc.mEngine.SetDirty;
- scrapDirty := true;
- end;
- end; {DoCut}
-
- {----------}
- Procedure Stuff.DoCopy;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECopy (curTE);
- scrapDirty := true;
- end;
- end; {DoCopy}
-
- {----------}
- Procedure Stuff.DoPaste;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEPaste (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoPaste}
-
- {----------}
- Procedure Stuff.DoClear;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEDelete (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoClear}
-
- {----------}
- Procedure Stuff.DoSelectAll;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TESetSelect (0, 32767, curTE);
- end;
- end; {DoSelectAll}
-
- {----------}
- Procedure Stuff.DoShowClipboard;
- begin
- end; {DoShowClipboard}
-
- {----------}
- Function Stuff.DoCommand (
- inCommand: longint): Boolean;
- begin
- DoCommand := true;
- case inCommand of
- cmdUndo:
- DoUndo;
- cmdCut:
- DoCut;
- cmdCopy:
- DoCopy;
- cmdPaste:
- DoPaste;
- cmdClear:
- DoClear;
- cmdSelectAll:
- DoSelectAll;
- cmdShowClipboard:
- DoShowClipboard;
-
- otherwise
- DoCommand := false;
- end; {case}
- end;
-
- end.
-